//
//  BannerReusableView.m
//  TestDemo
//
//  Created by zhangwenqiao on 2018/12/13.
//  Copyright © 2018年 zhangwenqiao. All rights reserved.
//

#import "BannerReusableView.h"
#import "MyViewController.h"
#import "UIApplication+SkipTool.h"

@implementation BannerReusableView

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
//    self.banerArray = [NSMutableArray array];
    
}

- (SDCycleScrollView *)cycleScrollView {
    if (!_cycleScrollView) {
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width / 728 * 426) delegate:self placeholderImage:[UIImage imageNamed:@""]];
        _cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleAnimated;
        _cycleScrollView.autoScrollTimeInterval = 4.0;
        _cycleScrollView.placeholderImage = [UIImage imageNamed:@""];
        _cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
        [self addSubview:_cycleScrollView];
    }
    return _cycleScrollView;
}

- (void)setBanerArray:(NSMutableArray *)banerArray {
    _banerArray = banerArray;
    if (_banerArray.count > 0) {
        self.cycleScrollView.imageURLStringsGroup = _banerArray;
    }
}

#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", (long)index);
//    UINavigationController *nav = (UINavigationController *)[UIApplication sharedApplication].keyWindow.rootViewController.navigationController;
////    [nav pushViewController:[MyViewController new] animated:YES];
//    [nav pushViewController:[MyViewController new] animated:YES];
    
//    UINavigationController *navi = [[UIApplication sharedApplication] visibleNavigationController];
    UINavigationController *nav = [[UIApplication sharedApplication] visibleNavigationController];
    [nav pushViewController:[[MyViewController alloc]init] animated:YES];
}

// 滚动到第几张图回调
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
    NSLog(@">>>>>> 滚动到第%ld张图", (long)index);
}

- (void)setName:(NSString *)name {
    _name = name;
    NSLog(@"name--%@", _name);
}


@end
